<html>
<head>
<title>ASP.NET Validation Controls</title>
<!-- #include file="style.inc" -->
</head>
<body bgcolor="#ffffff">
<!--------------------------------------------------------------------------->
<span class="heading">RegularExpressionValidator</span> &nbsp; &nbsp; &nbsp;
<form runat="server" action="getvalue.aspx" method="post">
 <table border="0">

<tr>
  <td valign="top">Email</td>
  <td><input type="text" id="txtEmail" 
	maxlength="50" size="20" runat="server" />
	<asp:RequiredFieldValidator 
	id="valPRequired" runat="server"
           ControlToValidate="txtEmail"
           ErrorMessage="* invalid email address"
           Display="dynamic">
           *
      </asp:RequiredFieldValidator> <br />
     <asp:RegularExpressionValidator id="valRegular" runat="server"
           ControlToValidate="txtEmail"
          ValidationExpression=".*@.*\..*."
           Type="String"
           ErrorMessage="* You must enter your email address"
           Display="dynamic">
           Please enter valid ivalid email.
      </asp:RegularExpressionValidator>
  </td>
 </tr>
 </table>

<asp:ValidationSummary id="valSummary" runat="server"
     HeaderText="<b>The following errors were found:</b>"
     ShowSummary="true" DisplayMode="List" />

<hr />
Validation Enabled:
<asp:DropDownList AutoPostBack="True" id="lstEnabled" runat="server">
<asp:ListItem Text="True" /><asp:ListItem Text="False" /></asp:DropDownList>
<p />&nbsp; &nbsp;
<input type="submit" id="cmdConfirm" value="Submit" runat="server" onserverclick="ConfirmEntry">&nbsp; &nbsp;
<input type="submit" id="cmdCancel" value="Cancel" runat="server" onserverclick="CancelEntry">&nbsp; &nbsp;
</form>
<div id="outMessage" EnableViewState="False" runat="server" />
<script language="VB" runat="server">

Sub Page_Load()

  Dim objValidator As BaseValidator
  For Each objValidator In Page.Validators
    objValidator.Enabled = lstEnabled.SelectedItem.Text   
    objValidator.EnableClientScript=False
  Next
  
End Sub



Sub ConfirmEntry(objSender As Object, objArgs As EventArgs)
  outMessage.InnerHtml = "Page.IsValid returned <b>" & Page.IsValid & ".</b>"
End Sub

Sub CancelEntry(objSender As Object, objArgs As EventArgs)
  outMessage.InnerHtml = "Validation was not carried out."
End Sub

</script>
<!--------------------------------------------------------------------------->
<!-- #include file="foot.inc" -->
</body>
</html>

